home *** CD-ROM | disk | FTP | other *** search
-
- {
- if(true)
- {
- ScoreSubmitter = §§newclass(ScoreSubmitter,EventDispatcher);
- }
- }
-
- package Local.External.CMG
- {
- import flash.events.Event;
- import flash.events.EventDispatcher;
- import flash.net.URLLoader;
- import flash.net.URLRequest;
- import flash.net.URLRequestMethod;
- import flash.net.URLVariables;
-
- public class ScoreSubmitter extends EventDispatcher
- {
-
- public static const RETURNCODE_SUCCESS:* = 1;
-
- public static var gameVersion:String = "";
-
- public static var gameValidationCode:String = "";
-
- public static const RETURNCODE_REJECTED:* = 2;
-
- public static const RETURNCODE_INTERNALERROR:* = 5;
-
- public static const URL_SUBMITSCORE:* = "http://scores.crazymonkeygames.com/hs/regscores2.php";
-
- public static const URL_UPDATEGAME:* = "http://scores.crazymonkeygames.com/hs/pleaseupdate.php";
-
- public static var gameId:uint = 0;
-
- public static const SCORE_RESPONSE:String = "score_response";
-
- public static const RETURNCODE_WORKING:* = 0;
-
- public static const RETURNCODE_WRONGVERSION:* = 3;
-
- public static const URL_VIEWSCORES:* = "http://scores.crazymonkeygames.com/hs/listscores.php";
-
- public static const RETURNCODE_NETWORKERROR:* = 4;
-
- {
- if(true)
- {
- gameId = 0;
- if(true)
- {
- gameVersion = "";
- if(true)
- {
- gameValidationCode = "";
- if(true)
- {
- SCORE_RESPONSE = "score_response";
- if(true)
- {
- RETURNCODE_WORKING = 0;
- if(true)
- {
- RETURNCODE_SUCCESS = 1;
- if(true)
- {
- RETURNCODE_REJECTED = 2;
- }
- RETURNCODE_WRONGVERSION = 3;
- }
- RETURNCODE_NETWORKERROR = 4;
- }
- RETURNCODE_INTERNALERROR = 5;
- }
- URL_VIEWSCORES = "http://scores.crazymonkeygames.com/hs/listscores.php";
- }
- URL_SUBMITSCORE = "http://scores.crazymonkeygames.com/hs/regscores2.php";
- }
- URL_UPDATEGAME = "http://scores.crazymonkeygames.com/hs/pleaseupdate.php";
- }
- }
-
- private var m_UrlLoader:URLLoader = null;
-
- public function ScoreSubmitter()
- {
- if(true)
- {
- m_UrlLoader = null;
- super();
- }
- }
-
- public static function loadHighScorePage() : void
- {
- Utilities.goToUrl(URL_VIEWSCORES + "?id=" + gameId);
- }
-
- public static function loadUpdatePage() : *
- {
- Utilities.goToUrl(URL_VIEWSCORES + "?id=" + gameId);
- }
-
- private function onIoError(param1:Event) : *
- {
- dispatchEvent(new ServerResponseEvent(SCORE_RESPONSE,RETURNCODE_NETWORKERROR));
- }
-
- public function submitScore(param1:String, param2:Number, param3:String = null) : void
- {
- var _loc4_:* = undefined;
- var _loc5_:URLRequest = null;
- §§push(Utilities.trim(param1));
- if(true)
- {
- §§push(§§pop());
- if(true)
- {
- param1 = §§pop();
- gameVersion = Utilities.trim(gameVersion);
- §§push(param3);
- if(true)
- {
- if(§§pop() == null)
- {
- param3 = "";
- }
- else
- {
- addr41:
- param3 = Utilities.trim(param3);
- }
- gameValidationCode = Utilities.trim(gameValidationCode);
- §§push(gameId < 1);
- §§push(gameId < 1);
- if(true)
- {
- if(!§§pop())
- {
- §§pop();
- addr56:
- §§push(gameVersion == "");
- }
- §§push(§§pop());
- }
- if(!§§pop())
- {
- §§pop();
- addr62:
- §§push(gameValidationCode == "");
- }
- if(§§pop())
- {
- dispatchEvent(new ServerResponseEvent(SCORE_RESPONSE,RETURNCODE_REJECTED));
- return;
- }
- dispatchEvent(new ServerResponseEvent(SCORE_RESPONSE,RETURNCODE_WORKING));
- (_loc4_ = new URLVariables()).name = param1;
- _loc4_.score = param2;
- _loc4_.gameId = gameId;
- _loc4_.gameVersion = gameVersion;
- _loc4_.special = param3;
- _loc4_.key = MD5.encrypt(param1 + "|" + param2 + "|" + gameId + "|" + param3 + "|" + gameValidationCode);
- (_loc5_ = new URLRequest(URL_SUBMITSCORE)).method = URLRequestMethod.POST;
- if(true)
- {
- _loc5_.data = _loc4_;
- if(true)
- {
- m_UrlLoader = new URLLoader();
- if(true)
- {
- m_UrlLoader.addEventListener("complete",onComplete);
- }
- m_UrlLoader.addEventListener("ioError",onIoError);
- }
- m_UrlLoader.load(_loc5_);
- }
- return;
- }
- §§goto(addr41);
- }
- §§goto(addr56);
- }
- §§goto(addr62);
- }
-
- private function onComplete(param1:Event) : void
- {
- var _loc2_:URLVariables = null;
- var _loc3_:* = undefined;
- _loc2_ = new URLVariables(m_UrlLoader.data.replace("&",""));
- _loc3_ = Utilities.trim(_loc2_.ok);
- if(true)
- {
- if(_loc3_ == 1)
- {
- if(true)
- {
- dispatchEvent(new ServerResponseEvent(SCORE_RESPONSE,RETURNCODE_SUCCESS));
- if(true)
- {
- §§goto(addr88);
- }
- else
- {
- addr68:
- dispatchEvent(new ServerResponseEvent(SCORE_RESPONSE,RETURNCODE_WRONGVERSION));
- }
- }
- }
- else if(_loc3_ == 0)
- {
- if(true)
- {
- dispatchEvent(new ServerResponseEvent(SCORE_RESPONSE,RETURNCODE_REJECTED));
- }
- }
- else if(_loc3_ != 2)
- {
- dispatchEvent(new ServerResponseEvent(SCORE_RESPONSE,RETURNCODE_INTERNALERROR));
- }
- §§goto(addr88);
- }
- addr88:
- }
- }
- }
-